import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { ObjCreate } from "../common/ObjCreate";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ImagesConst } from "../../resource/ImagesConst";
import { RedPackRankData } from "./RedPackRankData";
import { PlayerMiniInfo } from "../../model/PlayerMiniInfo";
import { PlayerOpRegister } from "../common/menu/PlayerOpRegister";
import { PlayerOpMenuConst } from "../common/menu/PlayerOpMenuConst";
//class RedPackRenderer
    
    export  class RedPackRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.initUI();
            return;
        }

        /* internal  */initUI(): void
        {
            this._rankTxt = ObjCreate.createTextField("1", 18, 0, 30, 20, this, GlobalStyle.textFormatRedPackRank);
            this._playerNameTxt = ObjCreate.createTextField("玩家名字七个字", 78, 0, 100, 20, this, GlobalStyle.textFormatRedPackRank);
            this._playerLv = ObjCreate.createTextField("100", 183, 0, 50, 20, this, GlobalStyle.textFormatRedPackRank);
            this._countTxt = ObjCreate.createTextField("8888", 245, 0, 70, 20, this, GlobalStyle.textFormatRedPackRank);
            this._goldTxt = ObjCreate.createTextField("8888888", 363, 0, 80, 20, this, GlobalStyle.textFormatRedPackRank);
            ObjCreate.createBg(0, 30, 475, 1, this, ImagesConst.SeptalLine);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            super.data = arg1;
            if (arg1.hasOwnProperty("data")) 
            {
                loc1 = arg1.data as RedPackRankData;
            }
            else 
            {
                loc1 = arg1 as RedPackRankData;
            }
            this._playerMiniInfo = new PlayerMiniInfo(loc1.rankInfo.miniPlayer);
            PlayerOpRegister.Register(this, this._playerMiniInfo, PlayerOpMenuConst.ChatOpMenu);
            this._playerNameTxt.htmlText = loc1.rankInfo.miniPlayer.name;
            this._playerLv.htmlText = String(loc1.rankInfo.miniPlayer.level);
            if (loc1.index != 0) 
            {
                if (loc1.index == 1) 
                {
                    this._rankTxt.htmlText = String(loc1.rankInfo.receiveRank);
                    this._countTxt.htmlText = String(loc1.rankInfo.inEnvNum);
                    this._goldTxt.htmlText = String(loc1.rankInfo.inGoldNum);
                }
            }
            else 
            {
                this._rankTxt.htmlText = String(loc1.rankInfo.sendRank);
                this._countTxt.htmlText = String(loc1.rankInfo.outEnvNum);
                this._goldTxt.htmlText = String(loc1.rankInfo.outGoldNum);
            }
            return;
        }

        /* internal */ /* var */_rankTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_playerNameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_playerLv: Object /* flash.text.TextField */;

        /* internal */ /* var */_fightingTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_countTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_goldTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_playerMiniInfo: PlayerMiniInfo;
    }
